<?php
namespace Plu\qdh\Models\App;

use Phalcon\Mvc\Model;

class Project extends Model
{

    //     CREATE TABLE `project` (
    //     `id` int(11) NOT NULL,
    //     `projectName` varchar(45) NOT NULL,
    //     `projectDescription` varchar(1024) DEFAULT NULL,
    //     `longitude` decimal(6,3) NOT NULL COMMENT '经度',
    //     `latitude` decimal(6,3) NOT NULL COMMENT '纬度',
    //     `imgs` varchar(1024) NOT NULL COMMENT '图片地址',
    //     `cover` varchar(100) NOT NULL COMMENT '封面图',
    //     `createTime` int(11) NOT NULL COMMENT '创建时间',
    //     `startTime` varchar(45) DEFAULT NULL,
    //     `endTime` varchar(45) DEFAULT NULL,
    //     `projectTips` varchar(1024) DEFAULT NULL COMMENT '小贴士',
    //     `phone` int(11) DEFAULT NULL,
    //     `projectPrompt` varchar(1024) DEFAULT NULL COMMENT '预定提示',
    //     `platformId` int(64) DEFAULT NULL,

    public function initialize() {
        $this->setConnectionService('db.qdh');
        $this->allowEmptyStringValues([]);
    }


	public function getSource() {
		return "project";
    }


    static public function getCount() {
        return self::count();
    }

    static public function getItemById($Id) {
        $item = self::findFirst([
            'conditions' => 'id = :Id:',
            'bind' => [
                'Id' => $Id
            ]
        ]);
        return $item;
    }

    static public function getItems($platformId = null) {
        $conditions = "1=1";
        if ($platformId) {
            $conditions = " platformId = $platformId ";
        }
        $items = self::find([
            'conditions' => $conditions,
            'order' => 'createTime asc'
        ]);
        if ($items) {
            return $items->toArray();
        }
        return [];
    }




}